package com.shujia.day16;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class CopyFileTest4 {
    public static void main(String[] args) throws Exception {
        //创建字符缓冲输入流对象
        BufferedReader br = new BufferedReader(new FileReader("java/src/com/shujia/day16/b3.txt"));
        //创建字符缓冲输出流对象
        BufferedWriter bw = new BufferedWriter(new FileWriter("java/src/com/shujia/day16/c3.txt"));

        //1、一次读写一个字符
//        int i = 0;
//        while ((i=br.read())!=-1){
//            bw.write(i);
//            bw.flush();
//        }

        //2、一次读写一个字符数组
//        char[] chars = new char[1024];
//        int length = 0;
//        while ((length = br.read(chars)) != -1) {
//            bw.write(chars, 0, length);
//            bw.flush();
//        }


        //3、一次读写一行
        String line = null;
        while ((line= br.readLine())!=null){
            bw.write(line);
            bw.newLine();
            bw.flush();
        }


        //释放资源
        bw.close();
        br.close();

    }
}
